package HomeWork.string;
/**
 * String 类型对象的8种常用方法的练习：
 * **/
public class StringDemo {
    public static void main(String[] args) {
        String str=" Live to change the world ";
        //length()
        System.out.println("length()");
        System.out.println(str.length());
        //trim()
        System.out.println("//trim()");
        System.out.println(str.trim());
        System.out.println("The length of new trimmed string is:"+(str.trim()).length());
        //to upper () lower
        System.out.println("//to upper () lower");
        System.out.println(str.toUpperCase());
        System.out.println(str.toLowerCase());
        //charAt()
        System.out.println("//charAt()");
        System.out.println(str.charAt(str.length()-1));
        System.out.println(str.charAt(4));
        //index of() last
        System.out.println("//index of() last");
        System.out.println(str.indexOf('c',2));
        System.out.println(str.lastIndexOf('d',str.length()-2));
        //end with () start
        System.out.println("//end with () start");
        System.out.println(str.startsWith("454"));
        System.out.println(str.endsWith("d"));
        //substring()
        System.out.println("//substring()");
        System.out.println(str.substring(1,5));
        //valueOf()
        System.out.println("//valueOf()");
        long lo=15131L;
        System.out.println(String.valueOf(lo));
    }
}
